/*
 * newMockFile.cpp
 *
 *  Created on: Oct 30, 2012
 *      Author: Federico Orquera
 */

#include "MockDefinitions.h"

std::string UpToLow(std::string str) {
    for (unsigned int i=0;i<str.size();i++)
        if (str[i] >= 0x41 && str[i] <= 0x5A)
            str[i] = str[i] + 0x20;
    return str;
}

BPTkey_t cropKey_func(const BPTkey_t& key, const BPTkey_t& prevKey){

	unsigned int i;
	for(i=0; ( i<prevKey.size() && prevKey[i]==key[i] ); i++);
	return  key.substr(0,i+1);

}

bool keyComparator_func(
	const BPTkey_t& key1,
	const BPTkey_t& key2
){
	return UpToLow(key1)<UpToLow(key2);
}

bool isOverflowLeaf_func (const LeafRegisterList_t& list){
	return ( list.size() > ORDER );
}

bool isUnderflowLeaf_func(const LeafRegisterList_t& list){
	return ( list.size() <= ( ORDER/2 + ORDER%2 ) );
}

bool isOverflowInternal_func (const InternalRegisterList_t& list){
	return ( list.size() > ORDER*2 );
}

bool isUnderflowInternal_func(const InternalRegisterList_t& list){
	return ( list.size() <= ( ORDER + ORDER%2 ) );
}
